import { Controller, Post, UploadedFile, UseInterceptors } from '@nestjs/common';
import { TransformInterceptor } from '../TransformInterceptor';
import { TextUpload, ImgUpload } from './decorator/upload.decorator';

@Controller('upload')
// 拦截器 请求前 请求后都能拦截
@UseInterceptors(new TransformInterceptor())
export class UploadController {
  @Post('image')
  @ImgUpload()
  image(@UploadedFile() file: Express.Multer.File) {
    console.log(file);
    return file;
  }

  @Post('text')
  @TextUpload()
  document(@UploadedFile() file: Express.Multer.File) {
    return file;
  }
}
